//
//  Vector_subscript.swift
//  SwiftyDSA
//
//  Created by Archer on 2018/8/5.
//  Copyright © 2018年 Archer. All rights reserved.
//

import Foundation

/// 通过下标存取元素
extension Vector {
    /// operator[]
    public subscript(index: Index) -> Element {
        set {
            precondition(index >= startIndex && index < endIndex, "index越界")
            _storage[index] = newValue
        }
        get {
            precondition(index >= startIndex && index < endIndex, "index越界")
            return _storage[index]
        }
    }
}
